package com.yuanluludev.lib_base.widget

import android.os.Bundle
import android.view.View
import androidx.fragment.app.FragmentManager
import com.yuanluludev.lib_base.R
import com.yuanluludev.lib_base.base.BaseDialogFragment
import kotlinx.android.synthetic.main.fragment_loading_dialog.*

/**
 * yuanLuLu
 * 加载弹窗
 */
class LoadingDialogFragment : BaseDialogFragment() {

    private var messageTip: String? = null

    companion object {
        fun newInstance() =
            LoadingDialogFragment()
    }

    override fun getLayoutResId() = R.layout.fragment_loading_dialog

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        tvMessage?.text = messageTip ?: "正在加载..."
    }

    fun show(
        fragmentManager: FragmentManager,
        messageTip: String,
        isCancelable: Boolean = false
    ) {
        this.messageTip = messageTip
        this.isCancelable = isCancelable
        try {
            show(fragmentManager, isCancelable)
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

}